TypeIdPair.cpp
Language: C++
Last Modified: 2021-10-23 9:47:57 PM UTC
File Size: 1111 bytes
Last Modified: 2021-10-23 9:47:57 PM UTC
File Size: 1111 bytes
http://www.penguinstew.ca/example/CodeFormater/TypeIdPair.cpp
#include "TypeIdPair.h"
#include <sstream>
#define TYPEPAIR_TYPE_ATTRIBUTE "type"
#define TYPEPAIR_ID_ATTRIBUTE "id"
TypeIdPair::TypeIdPair(std::string type, int id)
{
this->type = type;
this->id = id;
}
TypeIdPair::TypeIdPair(xmlNodePtr xmlNode)
{
type = "";
id = -1;
xmlChar* xmlString;
xmlString = xmlGetProp(xmlNode, xmlCharStrdup(TYPEPAIR_TYPE_ATTRIBUTE));
if (xmlString != NULL)
{
type = std::string((char*)xmlString);
}
xmlString = xmlGetProp(xmlNode, xmlCharStrdup(TYPEPAIR_ID_ATTRIBUTE));
if (xmlString != NULL)
{
if (xmlStrEqual(xmlString, xmlCharStrdup("*")) == 1)
{
id = -1;
}
else
{
id = atoi((char*)xmlString);
}
}
}
bool TypeIdPair::IsMatch(TypeIdPair testType)
{
return type.compare(testType.type) == 0 && (id == -1 || id == testType.id);
}
std::string TypeIdPair::ToString()
{
std::stringstream stream;
stream << "Type ID pair: ";
stream << "Type: " << this->type << ", ";
if (id < 0)
{
stream << "Id: Any";
}
else
{
stream << "Id: " << this->id;
}
return stream.str();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62